-- @owner:宋菲
-- @date:2024-03-15
-- @testpoint:1.测试创建触发器，触发器名称大小写不敏感，合理报错

--开启参数
set enable_ignore_case_in_dquotes to on;

--创建表及触发器函数
create table "t_ignore_case_in_dquotes_create_case0008"(col1 int,col2 varchar(10)); 
create or replace function "tri_func_ignore_case_in_dquotes_create_case0008"() returns trigger as
$$
declare
begin
    insert into "t_ignore_case_in_dquotes_create_case0008" values(new.id1, new.id2, new.id3);
    return new;
end
$$ language plpgsql;
/

--step1:创建触发器名为全小写;expect:成功 
create trigger "tri_ignore_case_in_dquotes_create_case0008_1"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step2:创建触发器名为全大写;expect:成功
create trigger "TRI_IGNORE_CASE_IN_DQUOTES_CREATE_CASE0008_2"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step3:创建触发器名为大小写混合;expect:成功
create trigger "tri_IgNOrE_CasE_IN_dquotes_create_cASe0008_3"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step4:创建触发器名带有特殊符号;expect:成功
create trigger "tri_IGNORE_CASE_IN_dquotes_create_CASE0008_!@#$%^&*()?<>:;=+-_4"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step5:创建触发器名带有单引号;expect:成功
create trigger "tri_IGNORE_CASE_IN_dquotes_create_CASE0008_'''_5"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step6:创建触发器名带有双引号;expect:成功
create trigger "tri_IGNORE_CASE_IN_dquotes_create_CASE0008_""""""_6"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step7:创建触发器名带有单引号、双引号混合;expect:成功
create trigger "TRI_IGNORE_CASE_IN_dquotes_create_case0008_''""_7"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step8:异常情况，创建已经存在的小写对象名的对象;expect:报错ERROR: already exists
create trigger tri_ignore_case_in_dquotes_create_case0008_8
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

create trigger "TRI_IGNORE_CASE_IN_DQUOTES_CREATE_CASE0008_8"
before insert on "t_ignore_case_in_dquotes_create_case0008"
for each row
execute procedure "tri_func_ignore_case_in_dquotes_create_case0008"();
/

--step9:清理环境:expect:成功(10 row)
drop trigger tri_ignore_case_in_dquotes_create_case0008_1 on t_ignore_case_in_dquotes_create_case0008;

drop trigger tri_ignore_case_in_dquotes_create_case0008_2 on t_ignore_case_in_dquotes_create_case0008;

drop trigger tri_ignore_case_in_dquotes_create_case0008_3 on t_ignore_case_in_dquotes_create_case0008;

drop trigger "tri_ignore_case_in_dquotes_create_case0008_!@#$%^&*()?<>:;=+-_4" on t_ignore_case_in_dquotes_create_case0008;

drop trigger "tri_ignore_case_in_dquotes_create_case0008_'''_5" on t_ignore_case_in_dquotes_create_case0008;

drop trigger "tri_ignore_case_in_dquotes_create_case0008_""""""_6" on t_ignore_case_in_dquotes_create_case0008;

drop trigger "tri_ignore_case_in_dquotes_create_case0008_''""_7" on t_ignore_case_in_dquotes_create_case0008;

drop trigger tri_ignore_case_in_dquotes_create_case0008_8 on t_ignore_case_in_dquotes_create_case0008;

drop table t_ignore_case_in_dquotes_create_case0008;

drop function tri_func_ignore_case_in_dquotes_create_case0008;
--关闭参数
set enable_ignore_case_in_dquotes to off;
